import threading
import time

my_list = list()

def write_data():
    for i in range(5):
        my_list.append(i)
        print("write:",i)
        time.sleep(0.1)
    print("write_data:",my_list)

def read_data():
    print("read_data:",my_list)

if __name__ == '__main__':
    write_thread = threading.Thread(target=write_data)
    read_thread = threading.Thread(target=read_data)
    write_thread.start()
    # 主线程等待该线程执行完毕后再向下执行
    write_thread.join()
    read_thread.start()